package com.jt.controller;

import com.alibaba.fastjson.JSON;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.client.discovery.DiscoveryClient;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * Created by Administrator on 2017/3/30.
 */
@RestController
public class GreetController {

    private static Logger logger = LoggerFactory.getLogger(GreetController.class);

    @Autowired
    DiscoveryClient discoveryClient;

    @RequestMapping(name = "/greet", method = RequestMethod.GET)
    public String greet() {
        logger.info("===================================");
        logger.info(JSON.toJSONString(discoveryClient));
        logger.info("===================================");
        return "hello world...";
    }

    @RequestMapping(name = "/add", method = RequestMethod.POST)
    public String add(@RequestParam("name") String name) {
        logger.info("***********************************");
        logger.info(JSON.toJSONString(discoveryClient));
        logger.info("name: " + name);
        logger.info("***********************************");
        return name;
    }


}
